package com.itany.springboot.controller;

import com.itany.springboot.entity.Emp;
import com.itany.springboot.entity.User;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;

@Controller
public class HelloController {

    @RequestMapping("/hello")
    public String hello(Map map){
        System.out.println("HelloController.hello()");

        map.put("message","<h1>Hello World</h1>");


        List<Emp> emps=new ArrayList<Emp>();

        for (int i = 0; i < 10; i++) {
            Emp emp=new Emp();
            emp.setId(i);
            emp.setName("emp"+i);
            emp.setSalary(2000.0*(i+1));
            emps.add(emp);
        }

        map.put("emps",emps);



        User user=new User();
        user.setId(1);
        user.setUsername("abc");
        user.setPassword("123");
        user.setSex("1");
        user.setEdu("1");
        user.setHobbies(new String[]{"1","3"});
        user.setDescription("abcd");
        user.setRegistDate(new Date());

        map.put("user",user);

        return "hello";
    }
}
